package tds.study.payment.pojo.vo;

import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;


/**
 * 自定义的分页返回信息。因为PageHelper的返回PageInfo没有swagger注解，无法生成在线文档注释
 *
 * @author TongDaShuai
 * @since 2021/9/30
 */
@Data
@NoArgsConstructor
public class PageVo<T> implements Serializable {


    private static final long serialVersionUID = -3536678043328625053L;

    /**
     * 当前页
     */
    @ApiModelProperty(value = "当前页", example = "1")
    private Integer pageNum;

    /**
     * 每页的数量
     */
    @ApiModelProperty(value = "每页的数量", example = "10")
    private Integer pageSize;

    /**
     * 当前页的数量
     */
    @ApiModelProperty(value = "当前页的数量", example = "3")
    private Integer size;

    /**
     * 总记录数
     */
    @ApiModelProperty(value = "总记录数", example = "10")
    private Long total;

    /**
     * 总页数
     */
    @ApiModelProperty(value = "总页数", example = "3")
    private Integer pages;

    /**
     * 结果集
     */
    @ApiModelProperty(value = "结果集", example = "")
    private List<T> list;

    public PageVo(PageInfo pageInfo) {
        this.pageNum = pageInfo.getPageNum();
        this.pageSize = pageInfo.getPageSize();
        this.size = pageInfo.getSize();
        this.total = pageInfo.getTotal();
        this.pages = pageInfo.getPages();
        this.list = pageInfo.getList();
    }


}
